<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta name="author" content="zhangcheng">
	<title>客户资料</title>
	<script type="text/javascript" src="../script/common.js" language="javascript" ></script>
	<!--动态js-->
	<script type="text/javascript">
			//全局变量
			var org = Common.cOrg();	//当前单位	
			var oper = Common.cOperator();
			setOrg(org);
			var qt = {};				//数据表格对象
			var cnt = {};
		function load(){
			Eui.showNavigation();//显示导航栏
			Eui.initBeginDateInput("beginDateTd","开始日期","searchForm","beginDate","endDate","_pastDate");
			Eui.initEndDateInput("endDateTd","结束日期","searchForm","beginDate","endDate","_pastDate");
			
			setPages(["listview","detview","editdiv"]);//切换页面
			//初始化select组件
			createTable();	
		}
		
	//生成表格，创建QueryTable对象(查询)
	function createTable(){
				var columns = [];
				columns[0] = {type:"checkbox"};
				
				columns[16]= {title:"操作",width:"15%",render:operationFunc,order:false};													
				discolumns = [0,1,2,3,4,5,16]
				qt = new QueryTable("publicInfo","searchForm","datalist",columns,{
				displayColumns:discolumns,
				
				paramFunc: function(){
						return {
						oper: searchForm.oper.value = oper.id
						};
					},
					
					buttons:[
						{value:"增 加",actions:onNew}
					]
				});
			}
			
			
	function operationFunc(v,r){
			return "<div style='color:gray'><a href=# onclick=onEidt('"+r[0]+"')>查看</a>";
		}
			
			
		function onNew(){
			Rpc.loadPage("editdiv","/oa/newsView.html")
			switchPage('editdiv');
		}
			
		function importFile(){
		
			var options = {}
			options.headFile = "VIPCustomer";
			var url = spellUrl("../common/import_data.html",options);
			openDialogFrame(url,"导入客户信息",800,1000);
		//	fileForm.reset();
		//	switchPage("fileView");
		}
		
		function onEidt(id){
			onNew()
			$("saveBut").onclick=onSave; 
			DWR.call("weekReportService.loadNews",id,function(data){
				var advice = data.publicInfo;
				
				Common.setValues(customerform,advice);
				
			});
		}
				
		function onSave(){
		if(!checkForm("customerform"))return;
		var advice = Common.getValues(customerform);
		DWR.call("weekReportService.saveNews",advice,function(result){
			showInformation("保存成功!");	
			onBack();
		},{blockScreen:"true"});
		
	}
	
	function onBack(){
		switchPage('listview');
		showData();
	}
				
	function showData(){
		searchForm.oper.value = oper.id;
	  	qt.showTable();
	}
		//显示静态明细
		function showDetail(id){
			switchPage("detview");
			CardMgnt.customer.show("customerview",id,CardMgnt.PERSONALALL,{showAll:true});
			CardMgnt.showViewForm(CardMgnt.customer.formName);
		}
		
		
		
	//选择机构方法
		function selectOrganization(b){
			var opts = {funcType : Constants.SELORG_ALL} //获得直属子节点
		
			if (b){
				SystemMgnt.selOrg(setSearchOrg,opts);
			}else{
				SystemMgnt.selOrg(setOrg,opts);
			}
		}
		
		        //searchform 选择机构 回调方法 
		function setSearchOrg(sorg){	
			searchForm.orgName.value = sorg.name;
			searchForm.organization.value = sorg.id;
		}
		
        //选择机构 回调方法
        function setOrg(sorg) {
        	selectedOrg = sorg;
            searchForm.reset();
            searchForm.org.value = sorg.id;
            searchForm.orgName.value = sorg.name;
        }
	//选择操作员
        function selOper() {
			SystemMgnt.selOperator(function(v) {
				if (!v) return;
				customerform.operName.value = v.name;
				customerform.oper.value = v.id;
//				searchForm.member.value = v.id;
			}, {orgId:selectedOrg.id})
		}
		

	</script>
</head>

<body onload="load()">
	<div class="nav"><div id="nav">&nbsp;</div></div>
	<div id="listview">	
		<!--查询条件form-->
		<div class="searchForm">			
			<form id="searchForm" name="searchForm">
					<table cellSpacing="0" cellPadding="4" width="100%" border="0"  class='col4 label3'> 
					<input type="hidden" name="oper" >
						<tr>
							<td id="beginDateTd"></td>
							<td id="endDateTd"></td>
							<td><button type="button" onclick="showData()">查 询</button></td>
						</tr>
					</table>				
			</form>
		</div>
		<div id="datalist"></div>
	</div>
	
	<div id="fileView" style="display:none;">
		<div class="listBorder">
		<form id="fileForm" name="fileForm" class="listForm" method="POST" enctype="multipart/form-data">
			<div class="formTitle">导入客户文件</div>
			<table id="tbl" cellSpacing=0 cellPadding=4 width="100%" border=0 class="col2">
				<tr>
					<td><label>导入客户文件</label> <input type="file" name="productionFile" class="file" size="60" onblur="checkV(this,'',true)"><span class="des">*</span></td> 
				</tr>
			</table>
		</form>
		</div>
		<p><button onclick="submitResultFile()">提 交</button> <button onclick="switchPage('listview')">返回</button></p>
	</div>
	
	<!--明细(新增/修改)页面部分-->
	<div id="detview" style="display:none;">
		<div id="customerview" class="form">
		</div>
		<p>
			<button onclick="switchPage('listview')">返 回</button>
		</p>
	</div>
	<div id=editdiv style="display:none;"></div>
</body>
</HTML>
	